package com.hxzy.common.resp;

import com.hxzy.common.enums.RCodeEnum;
import lombok.Getter;
import lombok.Setter;

/**
 * @author Administrator
 */
@Getter
@Setter
public class R {

    private int code;
    private String message;
    private Object data;

    /**
     * 构造方法
     * @param responseCode
     * @param data
     */
    public R(RCodeEnum responseCode, Object data) {
        this.code = responseCode.getCode();
        this.message = responseCode.getMessage();
        this.data = data;
    }




    public static R success() {
        return new R(RCodeEnum.SUCCESS,null);
    }

    public static R success(Object data) {
        return new R(RCodeEnum.SUCCESS, data);
    }

    public static R fail(RCodeEnum  rCodeEnum) {
        return new R(rCodeEnum,null);
    }



    public static R fail(RCodeEnum  rCodeEnum,String message) {
        R r = new R(rCodeEnum, null);
        r.setMessage(message);
        return r;
    }

}
